import http from '@/utils/request'
import { AuthApi } from '../auth'

/**账户信息 */
export interface UserInfo {
  id: string
  username: string
  email: string
  phone: string
  avatar: string
  name: string
  title: string
  job: string
  sex: string
  deptCCode: string
  deptName: string
  branchCode: string
  branchName: string
}

/**授权信息 */
export interface ResAuthButtons {
  [key: string]: string[]
}
interface MenuOptions {
  path: string
  name: string
  component: string
  meta: {
    icon: string
    title: string
    isLink: string
    isHide: boolean
    isFull: boolean
    isAffix: boolean
    isKeepAlive: boolean
  }
  children?: MenuOptions[]
}

/**员工用户名 */
const userCode = localStorage.getItem('userCode')
export const AccountAPI = {
  getUserInfo: () => http.get<UserInfo>(`/user/info?userCode=${userCode}`),
  getUserMenu: () => AuthApi.getAuthMenuList(),
  getUserButtons: () => AuthApi.getAuthButtonList(),
}
